@extends('admin.base')
    @section('content')
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <div class='col-md-6'>
          <h3>
            商品信息展示表
            <small>preview of simple tables</small>
          </h3>
          </div>
          <div class='col-md-3 pull-right'>
            <form action="{{url('admin/goodsDetail')}}" method="get" class="sidebar-form">
            <div class="input-group">
              <input type="text" name="id" class="form-control" placeholder="输入ID号"/>
              <span class="input-group-btn">
                <button type='submit' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i></button>
              </span>
            </div>
          </form>
          </div>
          <!-- <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商品信息</a></li>
            <li class="active">列表</li>
          </ol> -->

        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i>商品详情管理</h3>
                  （林莹莹要你补全<font style="color:blue">-newbook-</font>表的<font style="color:red">-{{$task['lin']}}-</font>条信息<font style='color:orange'>id:{{$task['linid']}}</font>）
                  （刘奇要你补全<font style="color:blue">-list-</font>表的<font style="color:red">-{{$task['liu']}}-</font>条信息<font style='color:orange'>id:{{$task['liuid']}}</font>）
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    @foreach ($list as $v)
                    <tr>
                      <!-- <th style="width:60px">id</th> -->
                      <th nobr><a href="{{url('admin/goodsDetail/')}}/{{$v->id}}/edit">pid</a></th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='pid' value='{{$v->pid}}'></td>
                      <th>状态</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='status' value='{{$v->status}}'></td>
                      <th>作者</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='auth' value='{{$v->auth}}'></td>
                      <th nobr>出版社</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='chubanshe' value='{{$v->chubanshe}}'></td>
                      <th class="nobr">出版时间</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='chubantime' value='{{$v->chubantime}}'></td>
                      <td align="center" valign="center"><a href="{{url('admin/xx')}}?id={{$v->id}}">商品详情</a></td>
                      <td align="center" valign="center" colspan="3"><input style="border:0px;" size='20' biaoji='{{$v->id}}' name='title' value='{{$v->title}}'></td>
                      <td align="center" valign="center" onclick="doDel({{$v->id}})" >{{$v->id}}</td>
                    </tr>
                    <tr>
                      <th>版次</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='rank' value='{{$v->rank}}'></td>
                      <th>市场价</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='marketPrice' value='{{$v->marketPrice}}'></td>
                      <th>优惠价</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='youhuiPrice' value='{{$v->youhuiPrice}}'></td>
                      <th>VIP价</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='vipPrice' value='{{$v->vipPrice}}'></td>
                      <th>是否有货</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='youhuo' value='{{$v->youhuo}}'></td>
                      <td align="center" valign="center" colspan="5" rowspan="2">内容：{{$v->contents}}</td>
                    </tr>
                    <tr>
                      <th>页数</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='goodsNum' value='{{$v->goodsNum}}'></td>
                      <th>字数</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='goodType' value='{{$v->goodType}}'></td>
                      <th>纯书名</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='goodName' value='{{$v->goodName}}'></td>
                      <th>关键字</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='keyWord' value='{{$v->keyWord}}'></td>
                      <th>是否促销</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='cuxiao' value='{{$v->cuxiao}}'></td>
                     
                    </tr>
                    <tr>
                      <th>印刷时间</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='marketTime' value='{{$v->marketTime}}'></td>
                      <th>开本</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='newGood' value='{{$v->newGood}}'></td>
                      <th>纸张</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='tuijian' value='{{$v->tuijian}}'></td>
                      <th>印次</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='jibie' value='{{$v->jibie}}'></td>
                      <th>包装</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='checked' value='{{$v->checked}}'></td>
                      <th align="center" >图片1<a href="javascript:void(0)" onclick="document.getElementById('myupup').click()"; style="color:red">upload</a><br><br><br><a href="javascript:void(0)" biaoji="{{$v->id}}" xixi="1" onclick="doUp(this)">ok</a></th>
                      <th align="center" >图片2<a href="javascript:void(0)" onclick="document.getElementById('myupup').click()"; style="color:orange">upload</a><br><br><br><a href="javascript:void(0)" biaoji="{{$v->id}}" xixi="2" onclick="doUp(this)">ok</a></th>
                      <th align="center" >图片3<a href="javascript:void(0)" onclick="document.getElementById('myupup').click()"; style="color:yellow">upload</a><br><br><br><a href="javascript:void(0)" biaoji="{{$v->id}}" xixi="3" onclick="doUp(this)">ok</a></th>
                      <th align="center" >图片4<a href="javascript:void(0)" onclick="document.getElementById('myupup').click()"; style="color:green">upload</a><br><br><br><a href="javascript:void(0)" biaoji="{{$v->id}}" xixi="4" onclick="doUp(this)">ok</a></th>
                      <th align="center" >图片5<a href="javascript:void(0)" onclick="document.getElementById('myupup').click()"; style="color:blue">upload</a><br><br><br><a href="javascript:void(0)" biaoji="{{$v->id}}" xixi="5" onclick="doUp(this)">ok</a></th>
                    </tr>
                    <tr>

                      <th>丛书名</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='click' value='{{$v->click}}'></td>
                      <th>是否上架</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='pinglun' value='{{$v->pinglun}}'></td>
                      <th>国际标准书号ISBN</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='jiaoyiNum' value='{{$v->jiaoyiNum}}'></td>
                      <th>所属分类</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='luruTime' value='{{$v->luruTime}}'></td>
                      <th>选择系列</th>
                      <td align="center" valign="center"><input style="border:0px;" size='3' biaoji='{{$v->id}}' name='xuanzexilie' value='{{$v->xuanzexilie}}'></td>
                      <td align="center" valign="center" id='q{{$v->id}}x1'><img id="myImg{{$v->id}}@1" src="{{url('uploads/admin')}}/{{empty($v->pic1)?'6.jpg':$v->pic1}}" width="100"></td>
                      
                      <td align="center" valign="center" id='q{{$v->id}}x2'><img id="myImg{{$v->id}}@2" src="{{url('uploads/admin')}}/{{empty($v->pic2)?'6.jpg':$v->pic2}}" width="100"></td>
                     
                      <td align="center" valign="center" id='q{{$v->id}}x3'><img id="myImg{{$v->id}}@3" src="{{url('uploads/admin')}}/{{empty($v->pic3)?'1.jpg':$v->pic3}}" width="100"></td>
                    
                      <td align="center" valign="center" id='q{{$v->id}}x4'><img id="myImg{{$v->id}}@4" src="{{url('uploads/admin')}}/{{empty($v->pic4)?'4.jpg':$v->pic4}}" width="100"></td>
                      
                      <td align="center" valign="center" id='q{{$v->id}}x5'><img id="myImg{{$v->id}}@5" src="{{url('uploads/admin')}}/{{empty($v->pic5)?'4.jpg':$v->pic5}}" width="100"></td>
                    </tr>
                    <tr>
                      <td align="center" valign="center" colspan="15"> <div style="border:1px solid red"></div></td>
                    </tr>
                   
                  @endforeach
                  </table>
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
                 
                </div>
              </div><!-- /.box -->

              {!! $list->render() !!}
              
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
        </form>
    @endsection
    
    
    @section("myscript")
      <script type="text/javascript">
            function doDel(id){
                if(confirm('确定要删除吗？')){
                    $("#mydeleteform").attr("action","{{url('admin/goodsDetail/')}}/"+id).submit(); 
                }
            }
      </script>
      <script type="text/javascript">
          $('input').blur(function(){
              
              //获取id
              var id = this.getAttributeNode('biaoji').value;

              //获取修改的值
              var val = this.value;

              //获取值的名字
              var name = this.getAttributeNode('name').value;

              $.ajax({
                url:"{{URL('admin/goodsDetail/')}}/"+id,
                type:"GET",
                data:{"id":id,"value":val,"name":name},
                dataType:"text",
                async:true,
                success:function(data){
                  return this;
                }
              });
          });
      </script>
      <form action="{{url('admin/doup')}}" method="post" enctype="multipart/form-data" style="display:none" id="myUpForm">
          <input type="file" name="myfile" id="myupup">
          <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
      </form>
      <!-- <input type="file" name="xx" id="xx" style="display:none" />
      <input type="button" id="btn" onclick="document.getElementById('xx').click();" /> -->
      <script type="text/javascript">
        function doUp(ob){

          //获取id
          var id = ob.getAttributeNode('biaoji').value;

          //获取biaoji
          var bj = ob.getAttributeNode('xixi').value;

          var uurrll = document.getElementById('myUpForm').action = "{{URL('admin/doup')}}?id="+id+"&bj="+bj;


          // $.ajax({
          //    url:uurrll,
          //    type:"POST",
          //    data:$('#myUpForm').serialize(),
          //    dataType:"text",
          //    async:true,
          //    success:function(data){
          //       alert(data);
          //    }
          // });
          
          var imgID = document.getElementById('myImg'+id+"@"+bj);
          // document.getElementById('myUpForm').submit();

          // document.getElementById('myUpForm').submit();
          var formData = new FormData($( "#myUpForm" )[0]);  
               $.ajax({  
                    url: uurrll ,  
                    type: 'POST',  
                    data: formData,  
                    async: false,  
                    cache: false,  
                    contentType: false,  
                    processData: false,  
                    success: function (returndata) {  
                        var address = "{{URL('uploads/admin')}}/"+returndata;
                        imgID.setAttribute('src',address);
                         
                    },  
                    error: function (returndata) {  
                        alert(returndata);  
                    }  
               });  

        }
      </script>
    @endsection